#include "sprite_sheet.h"
#include "engine/platform/resource_manager.h"

namespace kanon
{
    SpriteSheet::SpriteSheet(const std::string& file_path, uint32_t num_rows, uint32_t num_cols)
    {
        texture = get_texture(file_path);

        this->num_rows = num_rows;
        this->num_cols = num_cols;
    }

    glm::vec4 SpriteSheet::GetSubUV(uint32_t row, uint32_t col)
    {
        float stepx = 1.0f / this->num_cols;
        float stepy = 1.0f / this->num_rows;
        float x1 = col * stepx;
        float x2 = col * stepx + stepx;
        float y1 = row * stepy;
        float y2 = row * stepy + stepy;
        return glm::vec4(x1, y1, x2, y2);
    }
}
